class AppError extends Error {
    constructor(statusCode, message) {
        super(message);
        this.statusCode = statusCode;
        this.status = `${statusCode}`.startsWith('4') ? 'fail' : 'error';
        this.isOperational = true;

        Error.captureStackTrace(this, this.constructor);
    }
}

class ValidationError extends AppError {
    constructor(message) {
        super(400, message);
        this.name = 'ValidationError';
    }
}

class AuthenticationError extends AppError {
    constructor(message) {
        super(401, message);
        this.name = 'AuthenticationError';
    }
}

class AuthorizationError extends AppError {
    constructor(message) {
        super(403, message);
        this.name = 'AuthorizationError';
    }
}

class NotFoundError extends AppError {
    constructor(message) {
        super(404, message);
        this.name = 'NotFoundError';
    }
}

class DatabaseError extends AppError {
    constructor(message) {
        super(500, message);
        this.name = 'DatabaseError';
    }
}

module.exports = {
    AppError,
    ValidationError,
    AuthenticationError,
    AuthorizationError,
    NotFoundError,
    DatabaseError
}; 